<?
/**
* 
* database page, has the settings for database connection
*
* @author Patrick Lockley
* @version 1.0
* @copyright Copyright (c) 2008,2009 University of Nottingham
* @package
*/

/*
* Host where database is
*/
$xpert_site->database_host = "";

/*
* Username for database
*/
$xpert_site->database_username ="";

/*
* Password for database
*/
$xpert_site->database_password ="";

/*
* Database name
*/
$xpert_site->database_name ="";

/*
* Database table prefix
*/
$xpert_site->database_table_prefix ="";

/*
* Database table prefix
*/
$xpert_site->database_type = "mysql";


function xpert_database_connect($xpert_site){

	if($xpert_site->database_type=="mysql"){

		return mysql_connect($xpert_site->database_host, $xpert_site->database_username, $xpert_site->database_password);

	}

}

function xpert_database_select($xpert_site){

	if($xpert_site->database_type=="mysql"){

		@mysql_select_db($xpert_site->database_name) or die($database_fail = true);

	}

}

function xpert_database_select_query($query,$xpert_site){

	if($xpert_site->database_type=="mysql"){
	
		$query_response = mysql_query($query);

		return mysql_fetch_object($query_response);

	}

}

function xpert_database_multiple_select_query($query,$xpert_site){

	if($xpert_site->database_type=="mysql"){

		return mysql_query($query);		

	}

}

function xpert_database_fetch_object_from_response($response){

	return mysql_fetch_object($response);

}

function xpert_database_row_count($query,$xpert_site){

	if($xpert_site->database_type=="mysql"){

		$query_response = mysql_query($query);

		$data_result = array();

		array_push($data_result,mysql_num_rows($query_response));

		array_push($data_result,mysql_fetch_object($query_response));

		return $data_result;

	}

}

function xpert_database_insert_query($query,$xpert_site){

	if($xpert_site->database_type=="mysql"){

		$query_response = mysql_query($query);
		
		if(!query_response){
		
			return false;
			
		}else{

			return true;
			
		}

	}

}

function xpert_database_update_query($query,$xpert_site){

	if($xpert_site->database_type=="mysql"){

		$query_response = mysql_query($query);

		return mysql_fetch_object($query_response);

	}

}

function xpert_database_delete_query($query,$xpert_site){

	if($xpert_site->database_type=="mysql"){
	
		$query_response = mysql_query($query);

		return $query_response;

	}

}

function xpert_database_string_secure($string){

	return mysql_real_escape_string($string);

}

?>